package oom;

import java.util.ArrayList;
import java.util.List;

/**
 * 把OOM捕获了，还会生成日志吗
 * -Xmx20m -XX:+HeapDumpOnOutOfMemoryError
 */
public class CatchOOMDemo {
    public static void main(String[] args) {
        List<CatchOOMDemo> list = new ArrayList<>();
        try {
            for (; ; )
                list.add(new CatchOOMDemo());
        } catch (Error e) {
            System.out.println("发生异常: " + e.getMessage());
        }
    }
}
